package com.dunqi.gpm.shunqing.home.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by 空 on 2017/11/17 0017.
 */

public class ViewPagerFragmentAdapter extends FragmentPagerAdapter {


    private final String[] titls;
    private final ArrayList<Fragment> fragments;

    public ViewPagerFragmentAdapter(FragmentManager fm, ArrayList<Fragment> fragments, String[] titls) {
        super(fm);
        this.titls = titls;
        this.fragments = fragments;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titls[position];
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
